package com.oocl.myHomework.view;

import java.util.Scanner;

import com.oocl.myHomework.controller.Controller;
import com.oocl.myHomework.entity.Person;

public class View {
	Controller controller;
	
	
public void initial(){
		
	   controller = new Controller();
	   controller.initial();
	}
	public  void printList(Person... persons){
		   int number = 0;
		   System.out.println("|----------------------------------------------------------------------------|");
		   System.out.print("\tid\tname\tsex\tbirthday\taddress\tcall\t");
		   System.out.println("");
		   for(int i =0 ;i<persons.length;i++){
			   if(persons[i]!=null){
				   number ++;
			     System.out.print("\t"+persons[i].getId()+"\t"+persons[i].getName()+"\t"+persons[i].getSex()+"\t"+persons[i].getBirthday()+"\t"+persons[i].getAddress()+"\t"+persons[i].getCall());
			     System.out.println("");
		      }	       
		   }
		   System.out.println("|---------------------------------------------------------------------------|");
		   System.out.println("   "+number+" in total");
		   
	   }
	
	
	public  void helpView(){
		System.out.println("==========================");
		System.out.println("L.look up");
		System.out.println("A.add");
		System.out.println("D.delete");
		System.out.println("U.update");
		System.out.println("O.order");
		System.out.println("H.help");
		System.out.println("Q.quit");
		System.out.println();
		System.out.println("===========================");
		System.out.println("please input the letter which operation your want:");
		System.out.println("");
   } 
	
	
	public  void showCurCommand(String commandStr){
    	System.out.println("|-----------------------------------|");
    	System.out.println("     command:"+ commandStr);
    	System.out.println("|-----------------------------------|");
    }
	
	
	public void mainPage() throws Exception{
    	System.out.println("Welcome to the system!");
    	helpView();
		while(true){
			Scanner input =new Scanner(System.in);
	    	String commandstr = input.nextLine();
	    	if(commandstr.equals("Q")){
	    		System.out.println("Quit");
	    		break;
	    	}else{
			   controller.operationChoice(commandstr);
	    	}
		}
	}
}
